package Game;

import java.awt.*;
import java.applet.*;
import java.net.*;

public abstract class GameObject extends Applet
{
	private static final long serialVersionUID = 1L;
	public Image imagem;
	public int w, h;
	public float x, y;
	

	public GameObject(float x, float y, int width, int height)
	{
		this.x = x;
		this.y = y;
		this.w = width;
		this.h = height;
	}

	public boolean Collision(GameObject object)
	{
		return (this.x < object.x + object.w &&
				this.x + this.w > object.x   &&
				this.y < object.y + object.h &&
				this.y + this.h > object.y   );
	}
	
	protected URL getURL(String nomedoarquivo)
	{
		URL url = null;
		
		try
		{
			url = this.getClass().getResource(nomedoarquivo);
		}
		catch (Exception e) 
		{
			
		}
		return url;
	}

	public void Load(String nomedoarquivo)
	{
		Toolkit tk = Toolkit.getDefaultToolkit();

		imagem = tk.getImage(getURL(nomedoarquivo));
	}

	public  void Update()
	{

	}

	public void Draw(Graphics g)
	{
		g.drawImage(imagem, (int)x, (int)y, w, h, this);
	}

	
}
